Repository navigation
SDK 0.3.0: drums mcp server and CLI, HTTPS-only token transport - #7
Merged
Merged
Conversation
This reverts commit ee24be6.
… other http URLs are refused unless --allow-insecure-http / DRUMS_ALLOW_INSECURE_HTTP=1 / allow_insecure_http=True Client and connect() run check_transport before any request: with a token, an http (not https) URL whose host is not localhost, 127.0.0.0/8 or ::1 raises InsecureTransport. The CLI (drums mcp) maps that to a one-line stderr message and exit 2. The message names the host and the opt-ins, never the token.
…loopback and https allowed, the three opt-ins, no token in any message), --print-config never prints DRUMS_TOKEN or DRUMS_API_KEY, tools/list sends nothing
…oval; the HTTPS-only token rule and its opt-ins (README, skill, CHANGELOG 0.3.0)
…hops, with check_transport on every hop; any other redirect raises RedirectRefused unfollowed urllib's default redirect handler follows a 30x anywhere and re-sends every header, Authorization included, which would carry the token past check_transport to another host or to plain http. Client.call now opens requests through an opener whose HTTPRedirectHandler compares the hop target's (scheme, host, port) with the request's, refuses a different origin or a sixth hop with RedirectRefused (message: scheme, host and port of the target only), and runs check_transport on same-origin hops. 308 is handled like 307 on Pythons before 3.11. aio goes through Client.call and needs nothing of its own.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re-land of #3 (merged as 4cd3850, reverted as ee24be6) with the reviewer's conditions. Not published to PyPI; no tag. Version stays 0.3.0.
Contents
c08c689revert of the revert: the 0.3.0 content of drums mcp: two-layer MCP stdio server, drums CLI, Claude Code plugin #3 comes back as-is (drums mcpstdio server with the 34 tools ofdrums/mcp_tools.json, thedrumsconsole script,--print-config claude|claude-local|cursor|codex,Client.runs/create_run/run/api_keys/create_api_key/revoke_api_key/audit, the Claude Code plugin anddrums-workflowskill).d3ad482transport rule (new in this round, see below).52ca831tests for the rule and for--print-confignever printing a token.479bf53README, skill and CHANGELOG wording.d0626caredirect rule (reviewer finding on the first round, see below).Token transport rule
A token is sent over
https, or over plainhttpto loopback only (localhost,127.0.0.0/8,::1). With a token set, any otherhttp://URL from--url,DRUMS_URL,DRUMS_TOKEN_FILEor/etc/drums/tokenis refused before any request:drums.Client/drums.connectraise the newdrums.InsecureTransport(aDrumsError), so SDK scripts are covered, not just the CLI;drums mcpprints one line to stderr naming the host and the opt-ins and exits 2.The message never contains the token. Opt-ins:
drums mcp --allow-insecure-http,DRUMS_ALLOW_INSECURE_HTTP=1,Client(..., allow_insecure_http=True)/connect(..., allow_insecure_http=True).drums.check_transport(url, token, allow_insecure_http=None)is the check itself.--print-configis unaffected (it prints placeholders and sends nothing).Redirect rule
urllib's default handler follows any 30x and re-sends
Authorization, which would carry the token past the transport check.Client.callnow opens requests through an opener whoseHTTPRedirectHandlerfollows a redirect only to the same origin (scheme, host, port) as the request, at mostdrums.MAX_REDIRECTS(5) hops, and runscheck_transporton each hop; a redirect to another host or port, https to http, or a sixth hop raises the newdrums.RedirectRefusedbefore it is followed. Its message names the target's scheme, host and port only (no token, userinfo, path or query).308is handled like307on Pythons before 3.11.drums.aiowraps the syncClientin an executor, so it goes through the same opener.confirm: truewordingREADME, the skill and the CHANGELOG now say:
destroy_computer,delete_snapshotandrevoke_api_keyare refused before any request unless the tool arguments carryconfirm: true; the caller (the agent) supplies that argument, Drums does not prompt anyone, and approval of the call belongs to the MCP client (Claude Code, Cursor, Codex) and its tool-approval settings. There is no confirmation step inside Drums.resetis noted as discarding desktop state but is not gated (unchanged from #3;mcp_tools.jsonmirrors the gateway's list).Tests
python -m unittest discover -s tests: 76 tests, OK on Python 3.12.5 and 3.9.6 (the 53 of #3 plus 23 new:tests/test_transport.py, and additions totests/test_cli.pyandtests/test_mcp_server.py). They cover: off-loopback http refused with a token (Client, connect, CLI--url,DRUMS_URL, token file);http://localhost:7070,http://127.0.0.1,http://[::1]and https allowed; the flag, env var and kwarg opt-ins; no token in any refusal or exception text; all four--print-configformats with the token inDRUMS_TOKENand inDRUMS_API_KEYnever printing it;initializeandtools/listsending nothing to the gateway; redirects against a loopback server: cross-host, cross-port (a second loopback listener sees no connection), https-origin to http (the handler called as urllib calls it, with an https request URL), same-origin followed withAuthorizationon the second request, loop and chain capped at 5, no token/userinfo/query inRedirectRefused.